﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class Admin1_TaoTiDetail : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        InitData();
    }
    protected void InitData()
    {
        //Datacon DB = new Datacon();
        //int paperID = Convert.ToInt32(Request.QueryString["PaperID"].ToString());


        //SqlParameter[] Params1 = new SqlParameter[2];
        //Params1[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID);               //试卷编号
        //Params1[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "单选题");            //题目类型        
        //DataSet ds1 = DB.GetDataSet("Proc_PaperDetail", Params1);
        //GridView1.DataSource = ds1;
        //GridView1.DataBind();

        //SqlParameter[] Params2 = new SqlParameter[2];
        //Params2[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID);               //试卷编号
        //Params2[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "多选题");            //题目类型        
        //DataSet ds2 = DB.GetDataSet("Proc_PaperDetail", Params2);
        //GridView2.DataSource = ds2;
        //GridView2.DataBind();

        //SqlParameter[] Params3 = new SqlParameter[2];
        //Params3[0] = DB.MakeInParam("@PaperID", SqlDbType.Int, 4, paperID);               //试卷编号
        //Params3[1] = DB.MakeInParam("@Type", SqlDbType.VarChar, 10, "判断题");            //题目类型        
        //DataSet ds3 = DB.GetDataSet("Proc_PaperDetail", Params3);
        //GridView3.DataSource = ds3;
        //GridView3.DataBind();

        int paperID = Convert.ToInt32(Request.QueryString["PaperID"].ToString());
        using (DataClassesDataContext ds = new DataClassesDataContext())
        {
            GridView1.DataSource = from q in ds.SingleProblem
                                   join c in ds.TaoTiDetail on q.ID equals c.TitleID
                                   where c.Type=="单选题"
                                   where c.PaperID == paperID
                                   select q;
            GridView1.DataBind();

            GridView2.DataSource = from q in ds.MultiProblem
                                   join c in ds.TaoTiDetail on q.ID equals c.TitleID
                                   where c.Type == "多选题"
                                   where c.PaperID == paperID
                                   select q;
            GridView2.DataBind();

            GridView3.DataSource = from q in ds.JudgeProblem
                                   join c in ds.TaoTiDetail on q.ID equals c.TitleID
                                   where c.Type == "判断题"
                                   where c.PaperID == paperID
                                   select q;
            GridView3.DataBind();
            GridView4.DataSource = from q in ds.JianDaProblem
                                   join c in ds.TaoTiDetail on q.ID equals c.TitleID
                                   where c.Type == "简答题"
                                   where c.PaperID == paperID
                                   select q;
            GridView4.DataBind();
            GridView5.DataSource = from q in ds.LunShuProblem
                                   join c in ds.TaoTiDetail on q.ID equals c.TitleID
                                   where c.Type == "论述题"
                                   where c.PaperID == paperID
                                   select q;
            GridView5.DataBind();
        }

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("MangeTaoTi.aspx");
    }
}